public class Test4 {
    public static void main(String[] args) {
        //返回要删除的下标
        int[] nums = {3,2,2,3};
        int val = 3;
        int usedSize = nums.length;
        for(int i = 0;i < nums.length;i++){
            int index = -1;
            if(nums[i] == val){
                index = i;
            }
            //进行删除
            if(index != -1){
                for(int j = index;j < nums.length - 1;j++){
                    nums[j] = nums[j + 1];
                }
                nums[usedSize - 1] = 0;
                usedSize--;
            }
        }
        System.out.println(usedSize);
    }
}
